/* Copyright 2011 Elektrobit Wireless Communications Oy (EB)


  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License version 2 as 
  published by the Free Software Foundation.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License along
  with this program; if not, write to the Free Software Foundation, Inc.,
  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.


 *All rights reserved 
 *Version:Elektrobit_Qt_1.0.0_20110305 */


import Qt 4.7


Rectangle {
    property bool animationFinished: textAnimation.running

    id: window
    objectName: "welcomepage"
    width: 640
    height: 360
//    color: "#1A1A1A"
//    rotation: 90



    gradient: Gradient {
        GradientStop { position: 0.0; color: "#333333" }
        GradientStop { position: 1.0; color: "#FFFFFF" }
    }

    Image {
        id: eblogo
        source: "../images/sys/eblogo.gif"
        scale: 0.7
        x: 0
        y: 0
        visible: true
        opacity: 1

        SequentialAnimation on x {
            id: donghuaoneblogox
            running: true
//            NumberAnimation { to: ( window.width - eblogo.width )/2; duration: 1000 ; easing.type: Easing.InElastic}
            NumberAnimation { to: ( window.width - eblogo.width )/2; duration: 500 ; easing.type: Easing.OutCurve}
        }

        SequentialAnimation on y {
            id: donghuaoneblogoy
            running: true
//            NumberAnimation { to: ( window.height - eblogo.height)/2; duration: 2000 ; easing.type: Easing.Linear}
//            NumberAnimation { to: ( window.height - eblogo.height)/2; duration: 2000 ; easing.type: Easing.InOutBack}
//            NumberAnimation { to: ( window.height - eblogo.height)/2; duration: 2000 ; easing.type: Easing.InOutBounce}
            NumberAnimation { to: ( window.height - eblogo.height)/2; duration: 2000 ; easing.type: Easing.InBounce}
        }

        SequentialAnimation on opacity {
            NumberAnimation { to: 0; duration: 3000 }
        }
    }

    Image {
        id: qtlogo
        source: "../images/sys/qtlogo.png"
        scale: 0.7
        x: 640 - qtlogo.width
        y: 360 - qtlogo.height
        opacity: 1

        SequentialAnimation on x {
            id: donghuaonqtlogox
            running: true
//            NumberAnimation { to: ( window.width - qtlogo.width )/2; duration: 1000 ; easing.type: Easing.InElastic}
            NumberAnimation { to: ( window.width - qtlogo.width )/2; duration: 500 ; easing.type: Easing.OutCurve}
        }

        SequentialAnimation on y {
            id: donghuaonqtlogoy
            running: true
//            NumberAnimation { to: ( window.height - qtlogo.height)/2; duration: 2000 ; easing.type: Easing.Linear}
//            NumberAnimation { to: ( window.height - qtlogo.height)/2; duration: 2000 ; easing.type: Easing.InOutBounce}
            NumberAnimation { to: ( window.height - qtlogo.height)/2; duration: 2000 ; easing.type: Easing.InBounce}
//            NumberAnimation { to: (window.width - qtlogo.width )/2; duration: 1000 ; easing.type: Easing.InOutBack}
        }

        SequentialAnimation on opacity {
            NumberAnimation { to: 0; duration: 3000 }
        }
    }

    Text {
        id: appname
        opacity: 0
        text: "<b>GALLERY</b>"
        font.family: "Helvetica"
        font.pixelSize: 120
        color: "red"

        x: ( window.width - appname.width)/2
        y: ( window.height - appname.height)/2

//        PauseAnimation { duration: 1000 }
        SequentialAnimation on opacity {
//            ParallelAnimation {
//                NumberAnimation { from: 0; to: 1; duration: 4000 }
//                NumberAnimation { target: appname; property: "scale"; from: 0; to: 1; duration: 4000 }
//            }
            id: textAnimation
            ParallelAnimation {
                NumberAnimation { from: 0; to: 1; duration: 4000}
                NumberAnimation { target: appname; property: "scale"; from: 0; to: 0.5; duration: 4000 }
            }
//            NumberAnimation { from: 0; to: 1; duration: 4000}
//            NumberAnimation { target: appname; property: "scale"; from: 0; to: 0.5; duration: 4000 }

//            ParallelAnimation {
//                NumberAnimation { from: 1; to: 0; duration: 1000 }
//                NumberAnimation { target: appname; property: "scale"; from: 1; to: 0; duration: 1000 }
//            }
            ParallelAnimation {
                //NumberAnimation { from: 1; to: 0; duration: 1000 }
                NumberAnimation { target: appname; property: "scale"; from: 0.5; to: 1; duration: 1000 }
            }
//            NumberAnimation { from: 1; to: 0; duration: 1000 }
//            NumberAnimation { target: appname; property: "scale"; from: 0.5; to: 1; duration: 1000 }

        }
    }

    onAnimationFinishedChanged:{
        if(animationFinished == false) {
            //welcomepageFinished();
            welcomePageFinished();
        }
    }

}
